<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .router-link-active {
            color: red;
            font-weight: 800;
        }

        .myactiveclass {
            color: red;
        }

        .foo {
            font-weight: 800;
        }

        .v-enter, 
        .v-leave-to {
            opacity: 0;
            transform: translateX(150px);
        }
        .v-enter-active,
        .v-leave-active {
            transition: all 0.5s ease;
        }
    </style>
    <script src="./lib/vue2.4.4.js"></script>
    <script src="./lib/vue-router3.0.1.js"></script>
</head>

<body>
    <div id="app">
        <!-- <a href="#/login">登录</a>
        <a href="#/register">注册</a> -->
        <router-link to="/login" tag="span">登录</router-link>
        <router-link to="/register">注册</router-link>

        <transition mode="out-in">
            <router-view></router-view>
        </transition>
    </div>

    <template id="loginTpl">
        <h1>登录组件</h1>
    </template>
    <template id="registerTpl">
        <h1>注册组件</h1>
    </template>

    <script>

        var loginComponent = {
            template: '#loginTpl'
        }

        var registerComponent = {
            template: '#registerTpl'
        }

        var routerObj = new VueRouter({
            linkActiveClass: 'myactiveclass foo',
            routes: [
                {
                    path: '/',
                    // component: loginComponent
                    redirect: '/login'
                },
                {
                    path: '/login',
                    component: loginComponent
                }, {
                    path: '/register',
                    component: registerComponent
                }
            ]
        })

        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {},
            router: routerObj
        })
    </script>
</body>

</html>